// Volha  Charnysh 
// Explaining outgroup bias in weak states: religion and legibility in the 1891-92 Russian famine
// World Politics 
// Replication for Table A.4. Religion, language, and district-level mortality and natality during the famine with Conley standard errors. 


clear

cd "" //edit accordingly

use  "time-series-dataset.dta", sheet(Sheet 1) firstrow clear

keep if (aidgub == 1) 

// generate interaction terms
g famine_NOTorthodox = famine * sh_NOTorthodox_1870					// famine x non-orthodox

g famine_muslim = famine * sh_muslim_1870							// famine x share of Muslim
g famine_NotorthNotMuslim = famine * sh_NOTorthNotMuslim1870		// famine x share other Non-Orthodox

g famine_Turk = famine * ShareTurk									// famine x share Turkic
g famine_NonRusNonTurk = famine * ShareNonRusNonTurk				// famine x Share other Non-Russian

g famine_ostatokppLag = famine * ostatokppLag						// famine x harvest per capita (lag)
g famine_Urban = famine * UrbanShare1883							// famine x share urban

// generate constant column of 1s for program to work
g constant = 1

// encode panelvar
encode ter_id, generate(ter_id1) label(ter_id)

// generate dummy variables for ter_id and year because program does not take factor variables
tabulate year, gen(yrdum)
tabulate ter_id, gen(terdum)

// load program
do "Conley_Program.do"


// deaths per 1000
quietly eststo model1:ols_spatial_HAC est_cdr famine sh_NOTorthodox_1870 famine_NOTorthodox ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

quietly eststo model2:ols_spatial_HAC est_cdr famine sh_muslim_1870 famine_muslim sh_NOTorthNotMuslim1870 famine_NotorthNotMuslim ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

quietly eststo model3:ols_spatial_HAC est_cdr famine ShareTurk famine_Turk ShareNonRusNonTurk famine_NonRusNonTurk ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

// births per 1000
quietly eststo model4:ols_spatial_HAC est_cbr famine sh_NOTorthodox_1870 famine_NOTorthodox ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

quietly eststo model5:ols_spatial_HAC est_cbr famine sh_muslim_1870 famine_muslim sh_NOTorthNotMuslim1870 famine_NotorthNotMuslim ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

quietly eststo model6:ols_spatial_HAC est_cbr famine ShareTurk famine_Turk ShareNonRusNonTurk famine_NonRusNonTurk ostatokppLag famine_ostatokppLag UrbanShare1883 famine_Urban terdum1-terdum218 yrdum1-yrdum12 constant, lat(lat) lon(X) t(year) p(ter_id1) dist(900) lag(8) dropvar bartlett
quietly estadd local spacecut "900", replace
quietly estadd local nyear "8", replace
quietly estadd local ndist "217", replace

esttab model1 model2 model3 model4 model5 model6 using ConleyResults/tablea4.tex, cells(b(star fmt(2)) se(par fmt(2))) star(* 0.10 ** 0.05 *** 0.01) ar2 label collabels(none) replace booktabs alignment(D{.}{.}{-1}) keep(famine_NOTorthodox famine_muslim famine_NotorthNotMuslim famine_Turk famine_NonRusNonTurk ostatokppLag famine_ostatokppLag famine_Urban) order(famine_NOTorthodox famine_muslim famine_NotorthNotMuslim famine_Turk famine_NonRusNonTurk ostatokppLag famine_ostatokppLag famine_Urban) title(Religion, language, and district-level mortality and natality during the famine. Conley standard errors account for temporal (8 periods) and spatial correlation (up to 900 km).  Famine dummy is equal to one for 1892. \label{tab:taba4}) addnotes($^{*}$\textit{p}$<$0.1; $^{**}$\textit{p}$<$0.05; $^{***}$\textit{p}$<$0.01) mgroups("Deaths per 1,000 population" "Births per 1,000 population", pattern(1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) nomtitles varlabels(famine_NOTorthodox "Famine X non-Orthodox" famine_muslim "Famine X Share Muslims" famine_NotorthNotMuslim "Famine X Share Other Non-Orthodox" famine_Turk "Famine X Share Turkic" famine_NonRusNonTurk "Famine X Share Other Non-Russian" ostatokppLag "Harvest per capita (lag)" famine_ostatokppLag "Famine X Harvest per capita (lag)" famine_Urban "Famine X Share Urban") s(N r2_a spacecut nyear ndist,label("Num. obs" "Adj. R^2" "Spatial corr. kernel cutoff (km)" "Num. groups: year" "Num. groups: district") fmt(a3))
